import {Pipe, PipeTransform} from '@angular/core';

/**
 * 配件订单 支付方式 1：支付宝 2：微信 3：银联 6：对公转账
 */
export const partsOrderPayTypeArr = [
  {value: 1, label: '支付宝', color: '#1890ff'},
  {value: 2, label: '微信', color: '#52c41a'},
  {value: 3, label: '银联', color: '#909399'},
  {value: 6, label: '对公转账', color: '#faad14'}
];

@Pipe({
  name: 'partsOrderPayType'
})
export class partsOrderPayTypePipe implements PipeTransform {
  transform(value: any, type: number | string) {
    let tempObj: any = partsOrderPayTypeArr.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj?.label || '-';
    } else {
      return tempObj?.color || '#909399';
    }
  }
}

/**
 * 配件订单 状态
 * 0：有效 1：无效 2：待付款 3：待审核 4：审核不通过 5：审核通过 6：排队发货 7：待发货 8：待收货(已发货) 9：交易完成 10：支付超时 11：客服取消 12：客户取消 13：售后中 14：全部退货
 */
export const partsOrderStatusArrs = [
  {value: 0, label: '有效', color: '#606266'},
  {value: 1, label: '无效', color: '#606266'},
  {value: 2, label: '待付款', color: '#F56C6C'},
  {value: 3, label: '待审核', color: '#E6A23C'},
  {value: 4, label: '审核不通过', color: '#909399'},
  {value: 5, label: '审核通过', color: '#67C23A'},
  {value: 6, label: '排队发货', color: '#E6A23C'},
  {value: 7, label: '待发货', color: '#606266'},
  {value: 8, label: '待收货(已发货)', color: '#606266'},
  {value: 9, label: '交易完成', color: '#67C23A'},
  {value: 10, label: '支付超时', color: '#F56C6C'},
  {value: 11, label: '客服取消', color: '#F56C6C'},
  {value: 12, label: '客户取消', color: '#F56C6C'},
  {value: 13, label: '售后中', color: '#E6A23C'},
  {value: 14, label: '全部退货', color: '#F56C6C'}
];

@Pipe({
  name: 'partsOrderStatus'
})
export class PartsOrderStatusPipe implements PipeTransform {
  transform(value: any, type: number | string) {
    let tempObj: any = partsOrderStatusArrs.find((item: any) => item.value === value);
    if (type === 'label') {
      return tempObj?.label || '-';
    } else {
      return tempObj?.color || '#909399';
    }
  }
}